package com.diko.controller;

import com.aliyun.oss.OSSClient;
import com.diko.commonUtils.R;
import com.diko.service.fileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author Emma Li
 * @date 2020/9/21 - 12:11
 */
@Api(value = "阿里云文件管理")
@CrossOrigin
@RestController
@RequestMapping("/eduoss/fileoss")
public class controller {
    @Autowired
    private fileService fileService;

    @ApiOperation(value = "文件上传")
    @PostMapping("upload")
    public R upload(
            @ApiParam(name="file",value = "文件",required = true)
            @RequestParam("file")MultipartFile file){
        String uploadUrl=fileService.upload(file);
        return R.ok().message("文件上传成功").data("url",uploadUrl);
    }
}
